package Day11;

import Day09.UsernameNotFoundException;

import java.util.Scanner;

public class Login {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        System.out.println("请输入用户名");
        String name = sc.next();
        System.out.println("请输入密码");
        String password = sc.next();
        try {
            login(name, password);
        }catch(BadException e){
            e.printStackTrace();
        }catch(UsernameException e){
            e.printStackTrace();
        }
    }

    public static void login(String name, String password) throws BadException, UsernameException {
            if ("admin".equals(name)) {
                if ("123456".equals(password)) {
                    System.out.println("登录成功");
                }else{
                    throw new BadException("用户名或密码输入错误");
            }
        }else{
                throw new UsernameException("用户名输入错误");
            }
    }


}
